import React, { Component } from 'react';

class DingYue extends Component {
    render() {
        return (
            <div>
                发布订阅
            </div>
        );
    }
}

var bus={
    list:[],
    //订阅
    subscribe(callback){
        this.list.push(callback)
    },
    //发布
    publish(){
        //遍历所有list,将回调函数执行
        this.list.forEach(element => {
            element && element()
        });
    }
}
//订阅者
bus.subscribe(()=>{

})

//发布者
bus.publish()

export default DingYue;